# -*- coding:UTF-8-*-
import smtplib
from email import encoders
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr,formataddr

smtp_server = 'smtp.mxhichina.com'
from_addr = 'xiaojun.gao@socialcredits.cn'
password = 'Gao123456'
recevied = '1457252030@qq.com'
# smtp_server = 'smtp.qq.com'
# from_addr = '1457252030@qq.com'
# password = 'wpaswqvmizxjficc'
# recevied = '1457252030@qq.com'
def _format_addr(s):
    name,addr = parseaddr(s)
    return formataddr((Header(name,'utf-8').encode(),addr))
content = "Python 邮件发送测试...Python 邮件发送测试...Python\
          邮件发送测试...Python 邮件发送测试...Python 邮件发送测试\
          ...Python 邮件发送测试..."
msg = MIMEText(content,'plain','utf-8')
msg['From'] = _format_addr(from_addr)
msg['To'] = _format_addr(recevied)
msg['Subject'] = Header('邮件主题-测试','utf-8').encode()


s = smtplib.SMTP_SSL(smtp_server,465)
s.set_debuglevel(1) #打印debug日志
s.login(from_addr,password) #auth发件人信息
s.sendmail(from_addr,recevied,msg.as_string())
s.quit()
